1   /*
2    * Copyright (C) 2011 The Guava Authors
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.google.common.util.concurrent;
18  
19  import com.google.common.annotations.Beta;
20  
21  import java.util.concurrent.Callable;
22  import java.util.concurrent.ScheduledExecutorService;
23  import java.util.concurrent.TimeUnit;
24  
25  /**
26   * A {@link ScheduledExecutorService} that returns {@link ListenableFuture}
27   * instances from its {@code ExecutorService} methods. To create an instance
28   * from an existing {@link ScheduledExecutorService}, call
29   * {@link MoreExecutors#listeningDecorator(ScheduledExecutorService)}.
30   *
31   * @author Chris Povirk
32   * @since 10.0
33   */
34  @Beta
35  public interface ListeningScheduledExecutorService
36      extends ScheduledExecutorService, ListeningExecutorService {
37  
38    /** @since 15.0 (previously returned ScheduledFuture) */
39    @Override
40    ListenableScheduledFuture<?> schedule(
41        Runnable command, long delay, TimeUnit unit);
42  
43    /** @since 15.0 (previously returned ScheduledFuture) */
44    @Override
45    <V> ListenableScheduledFuture<V> schedule(
46        Callable<V> callable, long delay, TimeUnit unit);
47  
48    /** @since 15.0 (previously returned ScheduledFuture) */
49    @Override
50    ListenableScheduledFuture<?> scheduleAtFixedRate(
51        Runnable command, long initialDelay, long period, TimeUnit unit);
52  
53    /** @since 15.0 (previously returned ScheduledFuture) */
54    @Override
55    ListenableScheduledFuture<?> scheduleWithFixedDelay(
56        Runnable command, long initialDelay, long delay, TimeUnit unit);
57  }